using RuoVea.ConfigApp.Test.Controllers;
using RuoVea.ExDto;
using RuoVea.ExSugar;
using RuoVea.ExSwagger;
using RuoVea.OmiApp.Template;
using RuoVea.OmiApp.Template.Extensions;

namespace RuoVea.ConfigApp.Test
{
    /// <summary>
    /// 
    /// </summary>
    public class Program
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            builder.Services.AddLocalization();

            // Add services to the container.

            //builder.Services.AddControllers()
            //    .AddNewtonsoftJson(options =>
            //{
            //    //options.SerializerSettings.ContractResolver = new DefaultContractResolver();
            //    var dateConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter
            //    {
            //        DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
            //    };
            //    options.SerializerSettings.Converters.Add(dateConverter);
            //    //options.SerializerSettings.Culture = new CultureInfo("en-IE");
            //    options.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
            //})
            //    ;

            builder.Services.AddScoped<ICurrentUser, TestCurrentUser>();
            builder.Services.AddDictSetup( );

            builder.Services.AddSqlSugarSetup();
    
            builder.Services.AddSwaggerSetup();

            var app = builder.Build();

            app.UseOmiLocalization();

            // Configure the HTTP request pipeline.
            //if (app.Environment.IsDevelopment())
            //{
            //    app.UseSwagger();
            //    app.UseSwaggerUI();
            //}
            //app.UseSwaggerMiddle();

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseDictUI();

            app.UseAuthorization();

            app.MapControllers();

            app.Run();
        }
    }
}
